<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>jsTree v.1.0 - full featured jsTree</title>
	<script type="text/javascript" src="../js/jquery/jquery.js"></script>
	<script type="text/javascript" src="../js/jquery/jquery.cookie.js"></script>
	<script type="text/javascript" src="../js/jquery/jquery.hotkeys.js"></script>
	<script type="text/javascript" src="../js/jstree/jquery.jstree.js"></script>
	<script type="text/javascript" src="../js/tree.js"></script>

	<style type="text/css">
	html, body { margin:0; padding:0; overflow:hidden; }
	body, td, th, pre, code, select, option, input, textarea { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; }
	.jsTree, .jsTree input, .jstree-dnd-helper, #vakata-contextmenu { font-size:12px; font-family:Verdana; }
	#container { width:auto; margin:10px auto; overflow:hidden; position:relative; }
	#jsTree { width:100%; float:left; margin:0; border:0px solid gray; background:white; overflow:auto; }

	#text { margin-top:1px; }

	#alog { font-size:9px !important; margin:5px; border:1px solid silver; }
	</style>

	<link href="../js/toolbar/css/core.css" rel="stylesheet" type="text/css" />
	<link href="../js/toolbar/css/Toolbar.css" rel="stylesheet" type="text/css" />
	<script src="../js/toolbar/js/Toolbar.js" type="text/javascript"></script>
	<script type="text/javascript">
	var toolbar;
	$(document).ready(function() {
		toolbar = new Toolbar({
			renderTo : 'toolbar',
			//border: 'top',
			items : [ {
				type : 'button',
				title : '新建分类',
				bodyStyle : 'new-catalog',
				useable : 'T',
				handler : function() {
					doAction("createCatalog");
				}
			}, {
				type : 'button',
				title : '新建用例',
				bodyStyle : 'new-testcase',
				useable : 'T',
				handler : function() {
					doAction("createTestcase");
				}
			}, '-' ],
			active : 'ALL'//激活哪个
		});

		toolbar.render();
		//toolbar.genAZ();
	});
	</script>
	<script language="javascript">
	function doAction(action){
		pID=getParentNodeID();

		if (action == "createCatalog") {
			window.open("/testCaseMgt/catalogForm.jspx?action=create&pid="+pID, "", "width=" + window.screen.width*0.50 + ",height=120,left="+ window.screen.width*0.25 + ",top=" + (window.screen.height-350)/2 + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
		} else if (action == "createTestcase") {
			if (pID=="") {
				alert("请选择一个父分类！");
				return;
			} 
			window.open("/testCaseMgt/testCaseForm.jspx?action=create&pid="+pID, "", "width=" + window.screen.width*0.80 + ",height=" + window.screen.height*0.88 + ",left="+ window.screen.width*0.10 + ",top=" + window.screen.height*0.03 + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
		}
	}

	// 返回一个测试用例的父分类ID，如果是一个分类则返回次分类ID
	function getParentNodeID() {
		var pNodeID = "";
		var nodes = $.jstree._reference($("#jsTree")).get_selected();
		$.each(nodes, function(i, n) {
			var node=$.jstree._reference($("#jsTree"))._get_node(n);
			if (node.attr("rel")!="folder") {
				var pNode=$.jstree._reference($("#jsTree"))._get_parent(n);
				pNodeID=pNode.attr("id");
			} else {
				pNodeID=n.id;
			}
			return false;
		});
		return pNodeID;
	}

	function getWindowHeight() {
		if (window.innerHeight)
			return winHeight = window.innerHeight;
		else if ((document.body) && (document.body.clientHeight))
			return winHeight = document.body.clientHeight;
	}

	function jsTreeResize(obj) {
		var oWatermark = document.getElementById("jsTree");
		oWatermark.style.height = (getWindowHeight()-27)+"px";
	}
	window.onload = function() {
		window.onresize = jsTreeResize;
		jsTreeResize();
	}

	</script>
</head>
<body>
</body>
<div id="toolbar"></div>

<!-- the tree container (notice NOT an UL node) -->
<div id="jsTree" class="jsTree"></div>

</html>